﻿using roysland.net.designpatterns.MVVM;
using roysland.net.xcom.core.Models;

namespace roysland.net.xcom.editor.ViewModel
{
    public sealed class ObDataRecordViewModel : ViewModelBase
    {
        private readonly ObDataRecord _record;

        public ObDataRecordViewModel(ObDataRecord record)
        {
            _record = record;
            DisplayName = record.ObjectName;
        }

        #region Properties
        public ObDataRecord Record
        {
            get { return _record; }
        }
        public string ObjectName
        {
            get { return _record.ObjectName; }
        }

        public int BigObsIndex
        {
            get { return _record.BigObsIndex; }
        }

        public int AmmoDamageType
        {
            get
            {
                if (_record.AmmoDamageType == 255)
                    return 9;

                return _record.AmmoDamageType;
            }
            set
            {
                if (value == _record.AmmoDamageType)
                    return;

                _record.AmmoDamageType = (value == 9) ? 255 : value;

                OnPropertyChanged("AmmoDamageType");
            }
        }

        public int Damage
        {
            get { return _record.Damage; }
            set
            {
                if (value == _record.Damage)
                    return;

                _record.Damage = value;

                OnPropertyChanged("Damage");
            }
        }

        public int Weight
        {
            get { return _record.Weight; }
            set
            {
                if (value == _record.Weight)
                    return;

                _record.Weight = value;

                OnPropertyChanged("Weight");
            }
        }

        public int GrenadeType
        {
            get { return _record.GrenadeType; }
            set
            {
                if (value == _record.GrenadeType)
                    return;

                _record.GrenadeType = value;

                OnPropertyChanged("GrenadeType");
            }
        }

        public int AccuracyAimedShot
        {
            get { return _record.AccuracyAimedShot; }
            set
            {
                if (value == _record.AccuracyAimedShot)
                    return;

                _record.AccuracyAimedShot = value;

                OnPropertyChanged("AccuracyAimedShot");
            }
        }

        public int AccuracyAutoShot
        {
            get { return _record.AccuracyAutoShot; }
            set
            {
                if (value == _record.AccuracyAutoShot)
                    return;

                _record.AccuracyAutoShot = value;

                OnPropertyChanged("AccuracyAutoShot");
            }
        }

        public int AccuracySnapShot
        {
            get { return _record.AccuracySnapShot; }
            set
            {
                if (value == _record.AccuracySnapShot)
                    return;

                _record.AccuracySnapShot = value;

                OnPropertyChanged("AccuracySnapShot");
            }
        }

        public int TimeUnitsAutoShot
        {
            get { return _record.TimeUnitsAutoShot; }
            set
            {
                if (value == _record.TimeUnitsAutoShot)
                    return;

                _record.TimeUnitsAutoShot = value;

                OnPropertyChanged("TimeUnitsAutoShot");
            }
        }

        public int TimeUnitsAimedShot
        {
            get { return _record.TimeUnitsAimedShot; }
            set
            {
                if (value == _record.TimeUnitsAimedShot)
                    return;

                _record.TimeUnitsAimedShot = value;

                OnPropertyChanged("TimeUnitsAimedShot");
            }
        }

        public int TimeUnitsSnapShot
        {
            get { return _record.TimeUnitsSnapShot; }
            set
            {
                if (value == _record.TimeUnitsSnapShot)
                    return;

                _record.TimeUnitsSnapShot = value;

                OnPropertyChanged("TimeUnitsSnapShot");
            }
        }
        #endregion
    }
}
